﻿using System;
using System.ServiceModel;
using System.Collections.Generic;
using VNet.VisiSuite.Common.Resource;
using VNet.VisiSuite.Common.VNetChannelFactory;
using VNet.VisiSuite.Service.Contact.Message.Base;
using VNet.VisiSuite.Service.Interface;
using VNet.VisiSuite.Service.Contact.Message.Item;
using VNet.VisiSuite.Service.Contact.Message;
using VNet.VisiSuite.Common.Logger;

namespace VNet.VisiSuite.Service.Proxy
{
    public class VNetVisiSuiteContractClient : VNetChannelFactory<IVNetVisiSuiteService>, IVNetVisiSuiteService
    {
        #region Plants
        public GetDataResponse<IList<PlantItem>> GetPlants(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetPlants(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<PlantItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<PlantItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<IList<PlantItem>> UpdatePlants(SavePlantRequest request)
        {
            try
            {
                return ServiceCall(t => t.UpdatePlants(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<IList<PlantItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<IList<PlantItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<PlantItem> UpdatePlant(SaveDataRequest<PlantItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdatePlant(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<PlantItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<PlantItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<PlantItem> InsertPlant(SaveDataRequest<PlantItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertPlant(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<PlantItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<PlantItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }

        }

        public DeleteDataResponse DeletePlant(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeletePlant(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }

        }
        #endregion

        #region Users
        public GetDataResponse<IList<UserLoginItem>> GetUsers(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetUsers(request));
            }
            catch (TimeoutException)
            {
                return new GetDataResponse<IList<UserLoginItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new GetDataResponse<IList<UserLoginItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<UserLoginItem> UpdateUser(SaveDataRequest<UserLoginItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateUser(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<UserLoginItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<UserLoginItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<UserLoginItem> InsertUser(SaveDataRequest<UserLoginItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertUser(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<UserLoginItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<UserLoginItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public DeleteDataResponse DeleteUser(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteUser(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }
        

        #endregion

        #region Products
        public DeleteDataResponse DeleteProduct(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteProduct(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public GetDataResponse<IList<ProductItem>> GetProducts(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetProducts(request));
            }
            catch (TimeoutException)
            {
                return new GetDataResponse<IList<ProductItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new GetDataResponse<IList<ProductItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<ProductItem> UpdateProduct(SaveDataRequest<ProductItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateProduct(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<ProductItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<ProductItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<ProductItem> InsertProduct(SaveDataRequest<ProductItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertProduct(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<ProductItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<ProductItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<IList<ProductItem>> ImportProducts(SaveDataRequest<IList<ProductItem>> request)
        {
            try
            {
                return ServiceCall(t => t.ImportProducts(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<IList<ProductItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<IList<ProductItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        #endregion

        #region Production Plan
        public GetDataResponse<ProductionPlanReferenceItem> GetProductionPlanReference(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetProductionPlanReference(request));
            }
            catch (TimeoutException)
            {
                return new GetDataResponse<ProductionPlanReferenceItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new GetDataResponse<ProductionPlanReferenceItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public GetDataResponse<IList<ProductionPlanItem>> GetProductionPlans(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetProductionPlans(request));
            }
            catch (TimeoutException)
            {
                return new GetDataResponse<IList<ProductionPlanItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new GetDataResponse<IList<ProductionPlanItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<ProductionPlanItem> UpdateProductionPlan(SaveDataRequest<ProductionPlanItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateProductionPlan(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<ProductionPlanItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<ProductionPlanItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<ProductionPlanItem> InsertProductionPlan(SaveDataRequest<ProductionPlanItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertProductionPlan(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<ProductionPlanItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<ProductionPlanItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public DeleteDataResponse DeleteProductionPlan(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteProductionPlan(request));
            }
            catch (TimeoutException)
            {
                return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }

        public SaveDataResponse<IList<ProductionPlanItem>> ImportProductionPlans(SaveDataRequest<IList<ProductionPlanItem>> request)
        {
            try
            {
                return ServiceCall(t => t.ImportProductionPlans(request));
            }
            catch (TimeoutException)
            {
                return new SaveDataResponse<IList<ProductionPlanItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } };
            }
            catch (Exception)
            {
                return new SaveDataResponse<IList<ProductionPlanItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }
        }
        #endregion

        #region Areas

        #region Area
        
        public SaveDataResponse<AreaItem> UpdateArea(SaveDataRequest<AreaItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateArea(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<AreaItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<AreaItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<AreaItem> InsertArea(SaveDataRequest<AreaItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertArea(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<AreaItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<AreaItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }

        }

        public DeleteDataResponse DeleteArea(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteArea(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }

        }
        #endregion

        #region AreaShifts
        public GetDataResponse<IList<AreaShiftItem>> GetAreaShifts(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetAreaShifts(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<AreaShiftItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<AreaShiftItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<AreaShiftItem> InsertAreaShift(SaveDataRequest<AreaShiftItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertAreaShift(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<AreaShiftItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<AreaShiftItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<AreaShiftItem> UpdateAreaShift(SaveDataRequest<AreaShiftItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateAreaShift(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<AreaShiftItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<AreaShiftItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public DeleteDataResponse DeleteAreaShift(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteAreaShift(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }
        #endregion

        #region LaunchApplications
        public GetDataResponse<IList<LaunchApplicationItem>> GetLaunchApplications(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetLaunchApplications(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<LaunchApplicationItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<LaunchApplicationItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<LaunchApplicationItem> UpdateLaunchApplication(SaveDataRequest<LaunchApplicationItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateLaunchApplication(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<LaunchApplicationItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<LaunchApplicationItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<LaunchApplicationItem> InsertLaunchApplication(SaveDataRequest<LaunchApplicationItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertLaunchApplication(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<LaunchApplicationItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<LaunchApplicationItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public DeleteDataResponse DeleteLaunchApplication(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteLaunchApplication(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<IList<LaunchApplicationItem>> MoveLaunchApplication(SaveDataRequest<LaunchApplicationItem> request)
        {
            try
            {
                return ServiceCall(t => t.MoveLaunchApplication(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<IList<LaunchApplicationItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<IList<LaunchApplicationItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }
        #endregion

        #region ReasonCodes
        public GetDataResponse<IList<ReasonCodeItem>> GetReasonCodes(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetReasonCodes(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<ReasonCodeItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<ReasonCodeItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<ReasonCodeItem> InsertReasonCode(SaveDataRequest<ReasonCodeItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertReasonCode(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<ReasonCodeItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<ReasonCodeItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<ReasonCodeItem> UpdateReasonCode(SaveDataRequest<ReasonCodeItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateReasonCode(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<ReasonCodeItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<ReasonCodeItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public DeleteDataResponse DeleteReasonCode(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteReasonCode(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public GetDataResponse<IList<RollupDefinitionItem>> GetRollupDefinitionsAsSource(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetRollupDefinitionsAsSource(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<RollupDefinitionItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<RollupDefinitionItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }
        #endregion

        #region RollupDefinition
        public GetDataResponse<IList<RollupDefinitionItem>> GetRollupDefinitions(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetRollupDefinitions(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<RollupDefinitionItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<RollupDefinitionItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<RollupDefinitionItem> UpdateRollupDefinition(SaveDataRequest<RollupDefinitionItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateRollupDefinition(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<RollupDefinitionItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<RollupDefinitionItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<RollupDefinitionItem> InsertRollupDefinition(SaveDataRequest<RollupDefinitionItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertRollupDefinition(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<RollupDefinitionItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<RollupDefinitionItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }


        public DeleteDataResponse DeleteRollupDefinition(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteRollupDefinition(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<IList<RollupDefinitionItem>> MoveRollupDefinition(SaveDataRequest<RollupDefinitionItem> request)
        {
            try
            {
                return ServiceCall(t => t.MoveRollupDefinition(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<IList<RollupDefinitionItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<IList<RollupDefinitionItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }
        #endregion

        #region AlarmSetting
        public GetDataResponse<IList<AlarmSettingItem>> GetAlarmSettings(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetAlarmSettings(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<AlarmSettingItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<AlarmSettingItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<AlarmSettingItem> UpdateAlarmSetting(SaveDataRequest<AlarmSettingItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateAlarmSetting(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<AlarmSettingItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<AlarmSettingItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<AlarmSettingItem> InsertAlarmSetting(SaveDataRequest<AlarmSettingItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertAlarmSetting(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<AlarmSettingItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<AlarmSettingItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }


        public DeleteDataResponse DeleteAlarmSetting(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteAlarmSetting(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        #endregion

        #region ScrapReasonCodes
        public GetDataResponse<IList<ReasonCodeItem>> GetScrapReasonCodes(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetScrapReasonCodes(request));
            }
            catch (TimeoutException) { return new GetDataResponse<IList<ReasonCodeItem>> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<ReasonCodeItem>> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        #endregion

        #region Scheduled Downtime

        public GetDataResponse<IList<ScheduledDowntimeItem>> GetScheduledDowntimes(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetScheduledDowntimes(request));
            }
            catch (TimeoutException)
            {
                return new GetDataResponse<IList<ScheduledDowntimeItem>>
                {
                    Error = new ServiceError {Description = ErrorMessages.ServerTimeoutError}
                };
            }
            catch (Exception)
            {
                return new GetDataResponse<IList<ScheduledDowntimeItem>>
                {
                    Error = new ServiceError {Description = ErrorMessages.ServerError}
                };
            }
        }

        public SaveDataResponse<ScheduledDowntimeItem> UpdateScheduledDowntime(SaveDataRequest<ScheduledDowntimeItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateScheduledDowntime(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<ScheduledDowntimeItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<ScheduledDowntimeItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<ScheduledDowntimeItem> InsertScheduledDowntime(SaveDataRequest<ScheduledDowntimeItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertScheduledDowntime(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<ScheduledDowntimeItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<ScheduledDowntimeItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }


        public DeleteDataResponse DeleteScheduledDowntime(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteScheduledDowntime(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }


        #endregion

        #region Scheduled Repeat

        public GetDataResponse<IList<ScheduledRepeatItem>> GetScheduledRepeat(GetDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.GetScheduledRepeat(request));
            }
            catch (TimeoutException)
            {
                return new GetDataResponse<IList<ScheduledRepeatItem>>
                {
                    Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError }
                };
            }
            catch (Exception)
            {
                return new GetDataResponse<IList<ScheduledRepeatItem>>
                {
                    Error = new ServiceError { Description = ErrorMessages.ServerError }
                };
            }
        }

        public SaveDataResponse<ScheduledRepeatItem> UpdateScheduleRepeat(SaveDataRequest<ScheduledRepeatItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateScheduleRepeat(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<ScheduledRepeatItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<ScheduledRepeatItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<ScheduledRepeatItem> InsertScheduleRepeat(SaveDataRequest<ScheduledRepeatItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertScheduleRepeat(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<ScheduledRepeatItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<ScheduledRepeatItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }


        public DeleteDataResponse DeleteScheduledRepeat(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteScheduledRepeat(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }


        #endregion


        #endregion

        #region Cell

        public SaveDataResponse<CellItem> UpdateCell(SaveDataRequest<CellItem> request)
        {
            try
            {
                return ServiceCall(t => t.UpdateCell(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<CellItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<CellItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public SaveDataResponse<CellItem> InsertCell(SaveDataRequest<CellItem> request)
        {
            try
            {
                return ServiceCall(t => t.InsertCell(request));
            }
            catch (TimeoutException) { return new SaveDataResponse<CellItem> { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SaveDataResponse<CellItem> { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }

        }

        public DeleteDataResponse DeleteCell(DeleteDataRequest request)
        {
            try
            {
                return ServiceCall(t => t.DeleteCell(request));
            }
            catch (TimeoutException) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new DeleteDataResponse { Error = new ServiceError { Description = ErrorMessages.ServerError } }; }

        }
        #endregion

        #region Sync

        public ConfigureResponse VerifyCellAndGetServerData(ConfigureRequest request)
        {
            try
            {
                return ServiceCall(x => x.VerifyCellAndGetServerData(request));
            }
            catch (EndpointNotFoundException) { return new ConfigureResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new ConfigureResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception e) { return new ConfigureResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public ConfigureResponse SyncDataFromServerToClient(ConfigureRequest request)
        {
            try
            {
                return ServiceCall(x => x.SyncDataFromServerToClient(request));
            }
            catch (EndpointNotFoundException) { return new ConfigureResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new ConfigureResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception e) { return new ConfigureResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }
        
        
        public SyncDataFromClientResponse SyncDataFromClientToServer(SyncDataFromClientRequest request)
        {
            try
            {
                return ServiceCall(x => x.SyncDataFromClientToServer(request));
            }
            catch (EndpointNotFoundException) { return new SyncDataFromClientResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new SyncDataFromClientResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new SyncDataFromClientResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
      
        }

        #endregion

        #region VisiCentral

        public GetDataResponse<IList<CellItem>> GetCells(GetDataRequest request)
        {
            try
            {
                return ServiceCall(x => x.GetCells(request));
            }
            catch (EndpointNotFoundException) { return new GetDataResponse<IList<CellItem>> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new GetDataResponse<IList<CellItem>> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<IList<CellItem>> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
      
        }

        public ProductionDataResponse GetProductionData(ProductionDataRequest request)
        {
            try
            {
                return ServiceCall(x => x.GetProductionData(request));
            }
            catch (EndpointNotFoundException) { return new ProductionDataResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new ProductionDataResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception ex)
            {
                FileLog.Error("GetProductionData() - ", ex);
                return new ProductionDataResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } }; 
            }

        }

        public AnalysisChartDataResponse GetAnalysisChartData(AnalysisChartDataRequest request)
        {
            try
            {
                return ServiceCall(x => x.GetAnalysisChartData(request));
            }
            catch (EndpointNotFoundException) { return new AnalysisChartDataResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new AnalysisChartDataResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception ex)
            {
                FileLog.Error("GetAnalysisChartData() - ", ex);
                return new AnalysisChartDataResponse { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } };
            }

        }

        #endregion

#if DEBUG
        // TODO: Remove this region below on final build.
        #region Visi Central Test Data

        public GetDataResponse<bool> CreateDataTest()
        {
            try
            {
                return ServiceCall(x => x.CreateDataTest());
            }
            catch (EndpointNotFoundException) { return new GetDataResponse<bool> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new GetDataResponse<bool> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<bool> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } }; }
        }

        public GetDataResponse<bool> CreateProductionHistoryAtInterval()
        {
            try
            {
                return ServiceCall(x => x.CreateProductionHistoryAtInterval());
            }
            catch (EndpointNotFoundException) { return new GetDataResponse<bool> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServiceUrlInvalid } }; }
            catch (TimeoutException) { return new GetDataResponse<bool> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerTimeoutError } }; }
            catch (Exception) { return new GetDataResponse<bool> { Success = false, Error = new ServiceError { Description = ErrorMessages.ServerError } }; }

        }

        #endregion
#endif
    }
}